package com.sinder.campus_prophet.core.config;
import com.sinder.campus_prophet.core.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册web配置
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(new LoginInterceptor())
                .excludePathPatterns(
                        "/**",
                        "/error", // 白名单
                        "/druid"); // 白名单
        interceptorRegistration.excludePathPatterns("/**/*.html", "/**/*.jpg", "/**/*.png", "/**/*.jpeg"); // 静态资源白名单 -- 图片加载
    }
}